package Modelo;
import java.util.Iterator;
import java.util.LinkedList;

public class ListaCircular extends LinkedList {
	private int corriente;
	
	public Iterator iterator() {
		return new IteradorListaCircular(this);
	}
	
	public ListaCircular(){
		corriente=0;
	}
	
	public void agregar(Object o){
		this.add(o);
	}
	
	public void agregar(int n,Object o) throws RuntimeException{
		if(n<0)
			throw new RuntimeException();
		if(n>this.size())
			throw new RuntimeException();
		this.add(n,o);
	}
	
	public void eliminar(){
		this.remove(corriente);
		if(corriente>0)
			corriente--;
	}
	
	public void eliminar(int n){
		if(n<0)
			throw new RuntimeException();
		if(n>=this.size())
			throw new RuntimeException();
		this.remove(n);
	}
	
	public void vaciar(){
		if(!this.isEmpty())
			this.clear();
	}	
}